Conditionally showing linked Objects using Layout DXL

Hi all,

I have tried around programming some DXL Attributes which eventually even worked. It took me ages however and programming DXL is not my best feature. I've no experience in programming C++ either and my recently aquired Newby-DXL-knowledge has seemed to reach its outer limits.

I would like to show incoming links by using Layout DXL, created with the Link Analysis Wizard. Some of these links have an analysis depth of > 1, but I suppose that's of no relevance in this case.
My problem is that I do not want to show all incoming links. The linked object in the other module should only show up if a certain attribute of that linked object (e.g. attribute "x") has a certain value, say "yes".

My idea was to change the layout DXL into an DXL attribute (making the code available) and to additionally insert some kind of if-then-statement at the right place. However, when I look at the code after converting Layout DXL into attribute DXL i get the following:
 

/*
    Diese Attribut-DXL wurde erstellt am 16.11.2011 13:48:36.
*/
 
// prevent dxl timeout dialog
pragma runLim, 0
 
Buffer bsz = create
 
void endAttributeDXL()
{
    if (!null obj && attrDXLName != "")
    {
        obj.attrDXLName = richText tempStringOf(bsz)
    }
 
    delete bsz
}
 
void addNewLineSeparator(Buffer& b)
{
    if (length(b) > 0)
    {
        b += "\n"
    }
}
 
void display(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}
 
void displayRich(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}
 
void displayRichWithColour(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}
 
void displayRichWithColor(string s)
{
    addNewLineSeparator(bsz)
    bsz += s
}
 
void display(Attr__ a)
{
    string s = richText a
    if (!null s)
    {
        displayRich s
    }
}
 
//**********
 
// DXL generated by DOORS traceability wizard on 09 November 2011.
// Wizard version 2.0, DOORS version 9.2.0.5
pragma runLim, 0
string limitModules[2] = {"4a3769507c9d1362-00000bcd", "4a3769507c9d1362-00001983"}
string limitVersions[2] = {"", ""}
int lines[2] = {0, 0}
void adjustLines(int depth, showAtDepth) {
    int count
    for (count = 0; count < 2; count++) {
        while (lines[depth-1] < lines[count]) {
            if (depth == showAtDepth) displayRich("\\pard " " ")
            lines[depth-1]++
        }
    }
}
void showOut(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for l in all(o->linkModName) do {
        otherVersion = targetVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        if (!equal(getItem otherMod, (itemFromID limitModules[depth-1]))) continue
        if (versionString(otherVersion) != limitVersions[depth-1]) continue
        othero = target l
        if (null othero) continue
        if (isDeleted othero) continue
        int oldLines = lines[depth-1]
        adjustLines(depth, 2)
        bool kick = (doneOne) && (lines[depth-1] == oldLines)
        if (kick) {
            lines[depth-1]++
            if (depth == 2) displayRich("\\pard " " ")
        }
        if (depth < 2) {
            showOut(othero, depth+1)
        }
        doneOne = true
        if (depth == 2) {
            s = (identifier othero)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
            s = probeRichAttr_(othero,"Object Text", false)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }
        lines[depth-1] += 2
    }
}
showOut(obj,1)
 
//**********
 
endAttributeDXL()

 


I suppose the follwoing part is the interesting part and "othero" is the linked object in the other module. The value of the other objects attribute "x" would be of my interest, right?

 

 

 

if (depth == 2) {
            s = (identifier othero)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
            s = probeRichAttr_(othero,"Object Text", false)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)
        }



Any ideas? How should I bring in the if-then part for showing only certain links which fullfill the condition attribute "x" of the other object has value "yes"?



 

 


MHussaarts - Wed Nov 16 08:02:52 EST 2011

Re: Conditionally showing linked Objects using Layout DXL
OurGuest - Wed Nov 16 08:31:59 EST 2011

Before any displayRich put something in similar to following:

if(othero."X" "" =="yes") {...} else continue

Re: Conditionally showing linked Objects using Layout DXL
llandale - Wed Nov 16 14:57:48 EST 2011

OurGuest is on the right track.

I think the requirment is to completely ignore an object that has not value "Yes", and if so it seems he should insert your code above the depth check statement:

if (probeAttr_(othero, "X") != "Yes") continue
if (depth < 2) {
...

"probeAttr_" is an installed function that we are not supposed to know about but everybody uses. Its better than <othero."X" ""> because it does error checking, and will return a null string when attr "X" doesn't exist; whereas the straight way will cause a rude DXL abort.

  • Louie

Re: Conditionally showing linked Objects using Layout DXL
MHussaarts - Thu Nov 17 03:14:52 EST 2011

llandale - Wed Nov 16 14:57:48 EST 2011
OurGuest is on the right track.

I think the requirment is to completely ignore an object that has not value "Yes", and if so it seems he should insert your code above the depth check statement:

if (probeAttr_(othero, "X") != "Yes") continue
if (depth < 2) {
...

"probeAttr_" is an installed function that we are not supposed to know about but everybody uses. Its better than <othero."X" ""> because it does error checking, and will return a null string when attr "X" doesn't exist; whereas the straight way will cause a rude DXL abort.

  • Louie

@OurGuest and @Louie:

Thanks for the help, tried it and it works. Super. I wasn't sure were to insert the code (at which displayrich line) and inserted it before the depth-check as suggested by louie.

I Whish I had a decent Manual, I understand most of the code but just not 100% of it. Are there by any chance more DXL Manuels, other than the one provided by IBM? The IBM-Manual is like a swiss cheese.

Re: Conditionally showing linked Objects using Layout DXL
llandale - Thu Nov 17 13:22:28 EST 2011

MHussaarts - Thu Nov 17 03:14:52 EST 2011
@OurGuest and @Louie:

Thanks for the help, tried it and it works. Super. I wasn't sure were to insert the code (at which displayrich line) and inserted it before the depth-check as suggested by louie.

I Whish I had a decent Manual, I understand most of the code but just not 100% of it. Are there by any chance more DXL Manuels, other than the one provided by IBM? The IBM-Manual is like a swiss cheese.

It is a "reference" manual where you go to find out how a command works. There are some but not many sections that actually explain what is going on and how the commands work together to accomplish tasks.

There is some very old "tutorial" out there somewhere and of course IBM has the manual they give you as part of their $$$ DXL course.

If you go to the browse tool you can see a lot of small DXL programs. Perhaps you can read the code and also run the program as that may give you a better feel for how things are working; "recognition" is a good learning tool.

  • Louie